<?php

class Application_Form_Createuser extends Zend_Form {

    public function init() {
        #db
        $optionsDb = new Application_Model_Options();
        $userType = $optionsDb->getByName("userType");

        #
        $this->setMethod("post");

        #name
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel("Enter Name:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12', 'placeholder' => 'Enter name'));

        #user email
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel("Enter Email Address:")
                ->setAttribs(array('class' => 'span12', 'placeholder' => 'Enter Email Address'))
                ->setRequired()
                ->addFilter("StringTrim")
                ->addValidator("EmailAddress");

        #user type
        $type = new Zend_Form_Element_Select('type');
        $type->setLabel("Select User Type:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12'));
        $index = 0;
        foreach ($userType['details'] as $usertype) {
            $type->addMultiOption($index, $usertype);
            $index++;
        }

        #password
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel("Password:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12', 'placeholder' => 'Enter Password'));

        #details
        $details = new Zend_Form_Element_Textarea('details');
        $details->setLabel("Enter Details:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12', 'rows' => 4));

        #profileurl
        $profileUrl = new Zend_Form_Element_Text('profileUrl');
        $profileUrl->setLabel("Enter Profile Url:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12', 'placeholder' => 'Profile Url'));

        #id
        $id = new Zend_Form_Element_Hidden("id");
        $id->setValue(0);


        #submit
        $submit = new Zend_Form_Element_Submit("submit");
        $submit->setLabel("Create New User")
                ->setAttribs(array('class' => 'btn btn-success btn-large'));

        #
        $this->addElements(array($type, $name, $email, $password, $details, $profileUrl, $id, $submit));
    }

}

